import request from '@/utils/request'

export const login = (data) => {
  const params = new URLSearchParams()
  params.append('username', data.username)
  params.append('password', data.password)

  return request({
    url: '/api/auth/login',
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    data: params
  })
}

export const register = (data) => {
  return request({
    url: '/api/auth/register',
    method: 'post',
    headers: {
      'Content-Type': 'application/json'
    },
    data
  })
}

export const logout = () => {
  return request({
    url: '/api/auth/logout',
    method: 'post'
  })
}

export const getStatus = () => {
  return request({
    url: '/api/auth/status',
    method: 'get'
  })
}